<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"/>
    <link rel="stylesheet" href="__CSS__/common.css" />
    <link rel="stylesheet" href="__CSS__/myself_update.css" />
    <title>我的资料</title>
</head>
<body>
<div class="msg-box">
    <div class="msg-item">
        <div class="icon">
            <span>头像</span>
            <img src="{$user.head_pic}" alt="">
        </div>
    </div>
    <div class="msg-item">
        <div>
            <span>昵称</span>
            <div><input type="text" class="uname" placeholder="{$user.nickname}"></div>
        </div>
        <button class="btn" id="name">修改</button>
    </div>
    <div class="msg-item">
        <div>
            <span>所属地</span>
            <div><input type="text" class="usite" placeholder="{$user.address}"></div>
        </div>
        <button class="btn" id="site">修改</button>
    </div>
    <div class="msg-item">
				<div class="erweima">
						<span>微信二维码</span>
						<div class="camera">
								<img id="headimg" src="{$user.wxqr}" class="imageup"/>
								<input id="uploadAvatar" type="file" accept="image/*" multiple name="file" />
						</div>
				</div>				
			 <button class="btn" id="upload">上传</button>
		</div>
        <div class="msg-item">
            <div>
                <span>我的VIP等级</span>
                <span>LVI高级会员</span>
            </div>
        </div>
        <div class="msg-item">
            <div>
                <span>提升VIP等级</span>                
            </div>
            <a href="{:url('vip/index')}"><img src="__IMG__/right.png" alt=""></a>
        </div>
    </div>


   
    </div>
</body>
<script src="__JS__/jquery.min.js"></script>
<script src="__JS__/layer.js"></script>
<script>
$('#name').click(function(){
	    var add=$('.uname').val().trim();
        $.ajax({
            url:'/index/user/profile.html',
            data:{'nickname':add},
            type:'post',
            success:function(data) {
                if(data.code == 1) {
                    layer.msg(data.msg,{time:1500});
                }else{
                    layer.msg(data.msg,{time:1500});
                }
            }
        })
    });
    $('#site').click(function(){
	    var add=$('.usite').val().trim();
        $.ajax({
            url:'/index/user/profile.html',
            data:{'address':add},
            type:'post',
            success:function(data) {
                if(data.code == 1) {
                    layer.msg(data.msg,{time:1500});
                }else{
                    layer.msg(data.msg,{time:1500});
                }
            }
        })
    });
    // $('#upload').click(function(){
        var file = document.querySelector("#uploadAvatar");
        file.onchange = function(){
            var files = this.files[0];
            var formFile = new FormData();
            formFile.append("action", "UploadVMKImagePath");
            formFile.append("file", files);
            var data = formFile;
            $.ajax({
                url:'/index/user/uploadImg.html',
                data:data,
                type:'post',
                cache: false,//上传文件无需缓存
                processData: false,//用于对data参数进行序列化处理 这里必须false
                contentType: false, //必须
                dataType:'json',
                success:function(data) {
                    if(data.code == 1) {
                        layer.msg('上传成功',{time:1500});
                        //alert(data.data.src);
                        $("#headimg").attr('src',data.data.src);
                    }else{
                        layer.msg(data.msg,{time:1500});
                    }
                }
            })
        }
	//})

</script>
</html>